<?php

use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;


?>
<?php

NavBar::begin([
    'brandLabel' => Yii::$app->params['siteName'],
    'brandUrl' => Yii::$app->homeUrl,
    'options' => [
        'class' => 'navbar-inverse navbar-fixed-top',
    ],
]);
echo Nav::widget([
    'options' => ['class' => 'navbar-nav navbar-left'],
    'items' => [
        ['label' => '首页', 'url' => ['/']],
        ['label' => '问答', 'url' => ['/qa']],
        ['label' => '文章', 'url' => ['/article']],
        ['label' => '标签', 'url' => ['/tags']],
    ],
]);
echo Nav::widget([
    'options' => ['class' => 'navbar-nav navbar-right'],
    'items' => [
        Yii::$app->user->isGuest ? '' : ((Yii::$app->user->identity->rid == 1) ? '<li><a href="/admin/default">后台管理中心</a></li>' : ''),
        Yii::$app->user->isGuest ? '' : '<li class="dropdown">
        <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">撰写 <span class="caret"></span></a>
        <ul class="dropdown-menu" role="menu">
            <li><a href="/qa/create">提问题</a></li>
            <li><a href="/article/create">写文章</a></li>
        </ul>
        </li>',
        Yii::$app->user->isGuest ? '' : '<li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . Yii::$app->user->identity->username . ' <span class="caret"></span></a>
        <ul class="dropdown-menu" role="menu">
            <li><a href="/user">个人中心</a></li>
            <li><a href="/user/qa">我的问答</a></li>
            <li><a href="/user/article">我的文章</a></li>
            <li><a href="/user/comment">我的评论</a></li>
            <li class="divider"></li>
            <li><a href="/user/logout">退出登录</a></li>
            <li><a href="/site/help">帮助中心</a></li>
            <li><a href="/site/contact">意见反馈</a></li>
        </ul>
        </li>',
        Yii::$app->user->isGuest ? ['label' => '登录', 'url' => ['/user/login']] : '',
        Yii::$app->user->isGuest ? ['label' => '注册', 'url' => ['/user/register']] : '',
    ],
]);
NavBar::end();
?>